package ${controllerPackageName};

import ${domianPackageName}.${domain.className};
import ${servicePackageName}.${domain.className}Service;
import com.platform.common.domain.to.PageTo;
import com.platform.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
* ${(domain.comment)!} controller
*
* @author: ${domain.author}
* @version: 1.0
* @datetime: ${domain.datetime}
*/
@RestController
@Slf4j
public class ${domain.className}Controller {
    @Autowired
    private ${domain.className}Service ${domain.lowerStartClassName}Service;

    /**
     * 保存
     * @param ${domain.lowerStartClassName}
     * @return
     */
    @PostMapping(value = "/${domain.lowerClassName}s")
    public void save(@RequestBody ${domain.className} ${domain.lowerStartClassName}) throws Exception{
        ${domain.lowerStartClassName}Service.save(${domain.lowerStartClassName});
    }

    /**
     * 修改
     * @param ${domain.lowerStartClassName}
     * @return
     */
    @PutMapping(value = "/${domain.lowerClassName}s")
    public void modify(@RequestBody ${domain.className} ${domain.lowerStartClassName}) throws Exception{
        ${domain.lowerStartClassName}Service.modify(${domain.lowerStartClassName});
    }

    /**
     * 批量删除
     * @param ${domain.lowerStartClassName}
     * @return
     */
    @DeleteMapping(value = "/${domain.lowerClassName}s")
    public void remove(@RequestBody ${domain.className} ${domain.lowerStartClassName}) throws Exception{
        ${domain.lowerStartClassName}Service.remove(${domain.lowerStartClassName});
    }

    /**
     * 删除
     * @param ${domain.lowerStartClassName}Id
     * @return
     */
    @DeleteMapping(value = "/${domain.lowerClassName}s/{${domain.lowerStartClassName}Id}")
    public void remove(@PathVariable String ${domain.lowerStartClassName}Id) throws Exception{
        ${domain.lowerStartClassName}Service.remove(${domain.lowerStartClassName}Id);
    }

    /**
     * 根据主键查询id
     * @param ${domain.lowerStartClassName}Id
     * @return
     */
    @GetMapping(value = "/${domain.lowerClassName}s/{${domain.lowerStartClassName}Id}")
    public ${domain.className} findById(@PathVariable String ${domain.lowerStartClassName}Id) throws Exception{
        return ${domain.lowerStartClassName}Service.findById(${domain.lowerStartClassName}Id);
    }

    /**
     * 查询 -- 不分页
     * @return
     */
    @GetMapping(value = "/${domain.lowerClassName}s")
    public List<${domain.className}> find(${domain.className} ${domain.lowerStartClassName}) throws Exception{
        return ${domain.lowerStartClassName}Service.find(${domain.lowerStartClassName});
    }

    /**
     * 查询分页
     * @param ${domain.lowerStartClassName}
     * @param pageParam
     * @return
     */
    @PostMapping(value = "/${domain.lowerClassName}s/page")
    public PageInfo<${domain.className}> findPage(@ModelAttribute ${domain.className} ${domain.lowerStartClassName}, @ModelAttribute PageTo pageParam) throws Exception{
        return ${domain.lowerStartClassName}Service.findPage(${domain.lowerStartClassName}, pageParam);
    }
}
